import BNodeAction from "../base/BNodeAction";
import {ActionResult} from "../BTreeActionResult";
const {ccclass, property} = cc._decorator;
@ccclass
export default class BNodeWait extends BNodeAction {
    public startTime: number = 0;
    private waitDuration: number = 0;
    private milliseconds: number = 0;

    public enter(): void {
        this.startTime = (new Date()).getTime();
        this.waitDuration = this.parameter["milliseconds"] || 0;
    }

    public excute(): ActionResult {
        var currTime = (new Date()).getTime();
        if (currTime - this.startTime > this.waitDuration) {
            return ActionResult.SUCCESS;
        }
        return ActionResult.RUNNING;
    }
}
